﻿<?php
//程序入口配置
error_reporting( E_ALL ^ E_NOTICE );

define('CURR_HOST',$_SERVER["HTTP_HOST"]);
//$curr_host = $_SERVER["HTTP_HOST"];

// CACHE TIME CONSTANTs
define('CACHE_SECOND',      1);
define('CACHE_MINUTE',      60);
define('CACHE_HOUR',        3600);
define('CACHE_DAY',         86400);
define('CACHE_WEEK',        604800);
define('CACHE_MONTH',       2592000);
define('CACHE_YEAR',        31536000);
define('CACHE_TODAY',       strtotime("tomorrow") - time());

//Core DIR 配置
define('DS',         DIRECTORY_SEPARATOR);
define('ROOT_PATH', dirname(__FILE__) . DS);
define('CORE_PATH', ROOT_PATH . 'Core' . DS);
define('VENDOR_PATH', CORE_PATH . 'vendor' . DS);
define('LIB_PATH', CORE_PATH . 'lib' . DS);
define('PLUGIN_PATH', ROOT_PATH . 'Plugin' . DS);
define('LOG_PATH', ROOT_PATH . 'log' . DS);
//当前HOST地址
define('CURR_PROJECT_HOST',$_SERVER["HTTP_HOST"]);
//domain
$define_domain = 'whoopsfeed.com';
if(CURR_HOST == 'home.whoopsfeed.com'){//家里本机XAMPP环境
    $define_domain = 'whoopsfeed.com';
}

if(CURR_HOST == '192.168.83.219'){//公司自己虚拟机环境
    $define_domain = '192.168.83.219';
}

define('CURR_DOMAIN', $define_domain);

//常用配置
define('DEFAULT_DB_NAME', 'default');
define('MD5_PASSWORD','@user&&pwd@_zy!#%yz');
define('SHA1_CODE','@session&&need@_cookies');//服务器 session失效用
define('MD5_CODE','@verify&&code@__zy!#%yz');//通用验证 如 上传验证
define('START_TIME', microtime(true));
define('CHARSET',  'utf-8');

@header("Content-type: text/html; charset=".CHARSET);

//开发模式
define('RUNNING_MODE','dev');

//SESSION COOKIES 配置
//注意：session 相关配置修改要放到session_start()之前 也就是 本项目中 Session.class.php 之前
define('SESS_LIFTTIME',  86400);//缓存时间一天
define('PASSWORD_PREFIX',  'wf@p_p');
define('SESS_SAVE_PATH',  ROOT_PATH . 'session');

//不使用 GET/POST 变量方式
session_name(substr(SITE_PREFIX,0,-1));
//设置垃圾回收最大生存时间
session_cache_expire(SESS_LIFTTIME/60);
ini_set('session.gc_maxlifetime', SESS_LIFTTIME);
session_save_path(SESS_SAVE_PATH);

//程序调试配置
if (isset($_GET['debug']) && !defined('DEBUG'))
{
    define('DEBUG', true);
}
else
{
    define('DEBUG', false);
}

function exceptionDefaultHandler(Exception $e)
{
    l($e->getMessage(), 'default_exception');
}
set_exception_handler('exceptionDefaultHandler');

include CORE_PATH . 'config.php';
include CORE_PATH . 'function.php';

if (defined('RUNNING_MODE') &&  RUNNING_MODE == 'dev' && DEBUG)
{
    include LIB_PATH . 'Debug.class.php';

    if (function_exists('xhprof_enable')){
        xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);
    }

    /*
     * 1、当页面被用户强制停止时
     * 2、当程序代码运行超时时
     * 3、当ＰＨＰ代码执行完成时
     */
    register_shutdown_function('xhprof_save');
    register_shutdown_function('debug_info');
}

//程序基本类库
include LIB_PATH . 'VarStorage.class.php';//变量存储类
include LIB_PATH . 'Session.class.php';//session操作类
$_session = Session::getInstance();
include LIB_PATH . 'Input.class.php';//表单提交值过滤类
$_input = Input::getInstance();
/*-end-*/
include LIB_PATH . 'Model.class.php';//Model类
include LIB_PATH . 'Action.class.php';//Action类
include LIB_PATH . 'DataReader.class.php';//数据读取类
include LIB_PATH . 'DBReader.class.php';//数据库操作类
include LIB_PATH . 'Response.class.php';//返回值类
include LIB_PATH . 'DB.class.php';//DB类
include LIB_PATH . 'Upload.class.php';//文件上传类
include LIB_PATH . 'Template.class.php';//模板类
include LIB_PATH . 'CacheFile.class.php';//文件缓存类

?>